package com.hnd.springframerwork.beans;

import java.util.ArrayList;
import java.util.List;

/**
 * 属性集合
 */
public class PropertyValues {
   private List<PropertyValue> propertyValueList;

    public PropertyValues() {
        this.propertyValueList = new ArrayList<>();
    }

    public PropertyValues(List propertyValueList) {
        propertyValueList = propertyValueList == null ? new ArrayList() : propertyValueList;
    }

    public void addProperty(PropertyValue propertyValue) {
        propertyValueList.add(propertyValue);
    }

    public Object getProperty(String propertyName) {
        Object value = null;
        for (PropertyValue pv : propertyValueList) {
            if (pv.getName().equals(propertyName)) {
                value = pv.getValue();
                break;
            }
        }
        return value;
    }

    public PropertyValue [] getProperties() {
        return propertyValueList.toArray(new PropertyValue[0]);
    }
}
